# -*- coding: utf-8 -*-
"""
Created on Fri Jul 21 08:44:37 2023

@author: skunk69
"""

from mongoengine import DynamicDocument
from mongoengine import StringField, DictField

class Specific_Scales(DynamicDocument):
    # chinese_name = StringField(unique=True,required=True)
    # english_name = StringField(unique=True,required=True)
    # abbreviation = StringField(unique=True,required=True)
    # category = StringField(required=True)
    # outline = StringField()
    contents = DictField(required=True)
    # implementation = StringField()
    # measurements = DictField()
    # interpretation = StringField()
    # applications = StringField()
    
if __name__ == "__main__":
    
    # example：specific scale
    chinese_name = '生活事件量表'
    english_name = 'Life Event Scale'
    abbreviation = 'LES'
    category = u'应激及新冠行为量表'
    outline = u'概述'
    instruction = u'指导语'
    items = {1:u'恋爱或订婚',2:u'恋爱失败、破裂',3:u'结婚',4:u'自己（爱人）怀孕',
             5:u'自己（爱人）流产',6:u'家庭增加新成员',7:u'与爱人父母不和',
             8:u'夫妻感情不好',9:u'夫妻分居（因不和）',
             10:u'夫妻两地分居（工作需要）',49:'',50:''}
    title_items = u'生活事件名称'
    title_time_rating = u'事件发生时间'
    time_rating = ['未发生','1年前','1年内','长期性']
    title_characteristics_rating = u'性质'
    characteristics_rating = ['好事','坏事']
    title_level_influence_rating = u'精神影响程度'
    level_influence_rating = ['无影响','轻度','中度','中度','极重']
    title_duration_rating = u'影响持续时间'
    duration_rating = ['3个月内','半年内','1年内','1年以上']
    duration_score_rules = list(range(1,5))
    level_influence_score_rules = list(range(0,5))
    scales = ['家庭有关问题','工作学习中的问题','社交与其他问题','补充问题']
    L1 = list(range(1,29))
    L2 = list(range(29,42))
    L3 = list(range(42,49))
    L4 = list(range(49,51))
    scales_items = [L1,L2,L3,L4]
    implementation = u'实施方法'
    measurements = {'reliability':u'信度','validity':u'效度'}
    interpretation = u'结果分析方法'
    applications = u'应用情况'
 
    contents = {
        'instruction':instruction,
        'items':items,
        'title_items':title_items,
        'title_time_rating':title_time_rating,
        'time_rating':time_rating,
        'title_characteristics_rating':title_characteristics_rating,
        'characteristics_rating':characteristics_rating,
        'title_level_influence_rating':title_level_influence_rating,
        'level_influence_rating':level_influence_rating,
        'title_duration_rating':title_duration_rating,
        'duration_rating':duration_rating,
        'duration_score_rules':duration_score_rules,
        'level_influence_score_rules':level_influence_score_rules,        
        'scales':scales,
        'scales_items':scales_items      
                }
    
    LES = Specific_Scales(contents=contents)
    LES.chinese_name = chinese_name
    LES.english_name = english_name
    LES.category = category
    LES.outline = outline
    LES.implementation = implementation
    LES.measurements = measurements
    LES.interpretation = interpretation
    LES.applications = applications

    print(LES.to_json(indent=2,ensure_ascii=False))